import { axios } from '@/utils/request'

export function authToken (parameter) {
  parameter = {
    ...parameter,
    grant_type: 'password',
    scope: 'UPMS'
  }
  return axios({
    url: '/auth/oauth/token',
    headers: {
      'Authorization': 'Basic VVBNUzp1V2tNazNNdm5SM0Z4eA=='
    },
    method: 'post',
    params: parameter
  })
}

export function getSmsCaptcha (parameter) {
  return axios({
    url: '/account/sms',
    method: 'post',
    data: parameter
  })
}

export function getUserInfo () {
  return axios({
    url: '/upms/user/getUserInfo',
    method: 'get'
  })
}

export function logout (token) {
  return axios({
    url: '/auth/token/logout',
    headers: {
      'Authorization': `Bearer ${token}`
    },
    method: 'delete'
  })
}
